<template>
  <div>
    <el-button type="Importall" @click="dialogVisible=true">批量导入</el-button>
    <el-dialog title="批量导入" :visible.sync="dialogVisible" width="30%">
      <div class="dialog-body-box">
        <div class="tip-1">
          <span>1.下载模板文件，依据模板文件中的示例填写相应信息。</span>
          <span class="down-load">下载模板</span>
        </div>
        <div class="tip-2">
          <span>2.上传填写后的数据文件。</span>
        </div>
        <el-upload
          class="upload-demo"
          action="https://jsonplaceholder.typicode.com/posts/"
          :on-preview="handlePreview"
          :on-remove="handleRemove"
          :before-remove="beforeRemove"
          multiple
          :limit="3"
          :on-exceed="handleExceed"
          :file-list="fileList"
          :show-file-list="false"
        >
          <el-button size="small" type="upload">选择文件</el-button>
        </el-upload>
        <!--进度条组件-->
        <div class="Progress-box">
          <div class="Progress-item">
            <div class="item-name">这里是文件的名字.xlsx</div>
            <el-progress :percentage="50"></el-progress>
            <span class="x-border">x</span>
            <span class="x-no-border">x</span>
          </div>
          <div class="Progress-item">
            <div class="item-name">这里是文件的名字.xlsx</div>
            <el-progress :percentage="100" :format="format"></el-progress>
            <span class="x-border">x</span>
            <span class="x-no-border">x</span>
          </div>
          <div class="Progress-item">
            <div class="item-name">这里是文件的名字.xlsx</div>
            <el-progress :percentage="100" status="success"></el-progress>
            <span class="x-border">x</span>
            <span class="x-no-border">x</span>
          </div>
          <div class="Progress-item">
            <div class="item-name">这里是文件的名字.xlsx</div>
            <el-progress :percentage="50" status="exception"></el-progress>
            <span class="x-border">x</span>
            <span class="x-no-border">x</span>
          </div>
        </div>
      </div>
      <span slot="footer" class="dialog-footer">
        <el-button type="cancel" @click="dialogVisible = false">取 消</el-button>
        <el-button type="primary" @click="dialogVisible = false">确 定</el-button>
      </span>
    </el-dialog>
  </div>
</template>
<script>
export default {
  data() {
    return {
      dialogVisible: false,
      fileList: [
        {
          name: "food.jpeg",
          url:
            "https://fuss10.elemecdn.com/3/63/4e7f3a15429bfda99bce42a18cdd1jpeg.jpeg?imageMogr2/thumbnail/360x360/format/webp/quality/100",
        },
        {
          name: "food2.jpeg",
          url:
            "https://fuss10.elemecdn.com/3/63/4e7f3a15429bfda99bce42a18cdd1jpeg.jpeg?imageMogr2/thumbnail/360x360/format/webp/quality/100",
        },
      ],
    };
  },
  methods: {
    //图片上传------------
    handleRemove(file, fileList) {
      console.log(file, fileList);
    },
    handlePreview(file) {
      console.log(file);
    },
    handleExceed(files, fileList) {
      this.$message.warning(
        `当前限制选择 3 个文件，本次选择了 ${files.length} 个文件，共选择了 ${
          files.length + fileList.length
        } 个文件`
      );
    },
    beforeRemove(file, fileList) {
      return this.$confirm(`确定移除 ${file.name}？`);
    },
    //进度条组件----------
    format(percentage) {
      return percentage === 100 ? "√" : `${percentage}%`;
    },
  },
};
</script>
<style lang="less" scoped>
/deep/.el-dialog__wrapper {
  .el-dialog {
    width: 526px;
    border-radius: 8px 8px 8px 8px;

    //标题行，头部
    .el-dialog__header {
      background: rgba(230, 233, 237, 1);
      border-radius: 8px 8px 0px 0px;
      border: 1px solid rgba(230, 233, 237, 1);
      padding: 15px 0px 15px 24px;
      //sapn
      .el-dialog__title {
        font-size: 18px;
        font-weight: 550;
        color: rgba(51, 51, 51, 1);
        line-height: 16px;
      }
      //叉号
      .el-dialog__headerbtn {
        top: 13px;
        right: 17px;
      }
    }
    //表格主体
    .el-dialog__body {
      padding: 14px 20px 20px 20px;
      .tip-1 {
        font-size: 14px;
        font-weight: 400;
        color: rgba(51, 51, 51, 1);
        line-height: 30px;
        .down-load {
          margin-left: 10px;
          font-size: 14px;
          font-weight: 400;
          color: rgba(61, 127, 255, 1);
          line-height: 16px;
          text-decoration: underline;
          cursor: pointer;
        }
      }
      .tip-2 {
        font-size: 14px;
        font-weight: 400;
        color: rgba(51, 51, 51, 1);
        line-height: 30px;
        margin-bottom: 12px;
      }
      .el-button--upload {
        width: 100px;
        height: 36px;
        background: rgba(255, 255, 255, 1);
        border-radius: 2px;
        border: 1px solid rgba(61, 127, 255, 1);
        color: rgba(61, 127, 255, 1);
        font-size: 14px;
        margin-bottom: 20px;
      }
      //进度条盒子
      .Progress-box {
        .Progress-item {
          padding: 10px 0 15px 10px;
          background: rgba(247, 248, 250, 1);
          position: relative;
          margin-bottom: 10px;
          .item-name {
            font-size: 14px;
            font-family: PingFangSC-Regular, PingFang SC;
            font-weight: 400;
            color: rgba(51, 51, 51, 1);
            line-height: 20px;
          }
          /deep/.el-progress__text {
            font-size: 14px !important;
            line-height: 0px;
          }
          //带圆圈的x
          .x-border {
            display: inline-block;
            color: white;
            border-radius: 50%;
            width: 16px;
            height: 16px;
            background: rgba(204, 204, 204, 1);
            text-align: center;
            line-height: 12px;
            position: absolute;
            right: 0;
            top: 0;
          }
          .x-no-border {
            color: #666666;
            position: absolute;
            right: 70px;
            top: 25px;
            display: inline-block;
            width: 8px;
            height: 8px;
          }
          /deep/.el-progress-bar {
            width: 92%;
          }
          /deep/.el-progress__text {
            margin-left: 40px;
          }
        }
      }
    }
    //表格底部按钮
    .el-dialog__footer {
      //按钮盒子
      .dialog-footer {
        .el-button--cancel {
          width: 70px;
          height: 36px;
          background: rgba(255, 255, 255, 1);
          border-radius: 3px;
          border: 1px solid rgba(215, 219, 224, 1);
          color: rgba(51, 51, 51, 1);
          font-size: 14px;
        }
        .el-button--primary {
          width: 70px;
          height: 36px;
          background: rgba(61, 127, 255, 1);
          border-radius: 3px;
          color: rgba(255, 255, 255, 1);
          font-size: 14px;
        }
      }
    }
  }
}
</style>